<script id="pattern_keys" type="text/x-jquery-tmpl">
	<tr>
		<td>
			<span class="key type_${type}" href="">${k}</span>
		</td>
		<td>
			<a class="edit overlay_trigger" rel="#overlay_edit_key" href="<?php echo URL::site(Route::get('dires')->uri(array('controller'=>'dires', 'action'=>'key_rename')), null, false).'?k=' ?>">rename</a>
			<a class="view overlay_trigger ajax" rel="#general_overlay" href="<?php echo URL::site(Route::get('dires')->uri(array('controller'=>'dires', 'action'=>'key_view')), null, false).'?k=' ?>">contents</a>
			<a class="delete" href="<?php echo URL::site(Route::get('dires')->uri(array('controller'=>'dires', 'action'=>'key_delete')), null, false).'?k=' ?>">delete</a>
		</td>
	</tr>
</script>

<table id="pattern_list">
<?php
foreach ($patterns as $p) {
	?>
	<tr>
		<td>
			<a class="pattern" href="<?php echo URL::site(Route::get('dires')->uri(array('controller'=>'dires', 'action'=>'pattern_expand')), null, false).'?p='.urlencode($p) ?>"><?php echo HTML::entities($p) ?></a>
			<div></div>
		</td>
		<td>
			<a class="pattern_edit" data-pattern="<?php echo HTML::entities($p) ?>" href="<?php echo URL::site(Route::get('dires')->uri(array('controller'=>'dires', 'action'=>'pattern_edit')), null, false).'?p='.urlencode($p) ?>">edit</a>
			<a class="pattern_delete" href="<?php echo URL::site(Route::get('dires')->uri(array('controller'=>'dires', 'action'=>'pattern_delete')), null, false).'?p='.urlencode($p) ?>">delete</a>
		</td>
	</tr>
	<?php
} ?>
	<tr>
		<td>
			<a class="pattern" href="<?php echo URL::site(Route::get('dires')->uri(array('controller'=>'dires', 'action'=>'pattern_expand')), null, false).'?nopattern=1' ?>">&lt;unpatterned&gt;</a> (Note: expanding this will fail if your db is big!)
			<div></div>
		</td>
	</tr>
</table>

<div id="overlay_editpattern" class="overlay shadow">
	<a class="close">close</a>
	<h4>Edit a pattern</h4>
	<div class="block inner">
		<form action="<?php echo URL::site(Route::get('dires')->uri(array('controller'=>'dires', 'action'=>'pattern_edit')), null, false) ?>" method="post">
			<input type="hidden" name="old_key" value="" />
			<input type="text" name="key" />
			<input type="submit" value="change" />
		</form>
	</div>
</div>

